package io.jjz.pe;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterBase;

import java.io.IOException;

public class FilterAllFilter extends FilterBase {

  public FilterAllFilter() {
  }

  @Override
  public ReturnCode filterKeyValue(Cell v) throws IOException {
    return ReturnCode.SKIP;
  }

  // Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
  // See HBASE-12068
  @Override
  public Cell transformCell(Cell v) {
    return v;
  }

  @Override
  public boolean hasFilterRow() {
    return true;
  }

  @Override
  public boolean filterRow() throws IOException {
    return true;
  }

  public static FilterAllFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    // No options to parse, so why bother
    return new FilterAllFilter();
  }

  boolean areSerializedFieldsEqual(Filter o) {
    if (o == this)
      return true;
    if (!(o instanceof FilterAllFilter))
      return false;

    return true;
  }
}